<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>test</title>
	<script src="https://cdn.bootcss.com/jquery/1.12.2/jquery.min.js"></script>
</head>
<body>
<table>
	<tbody id="tbody"></tbody>
</table>

<script>
    //测试
    var data = {
        lst: [{
            a: "属性a1",
            b: "属性B1",
			c: "属性c1",
            sqr: "申请人1",
            status: 1,
            reason: "\r\n reason1"
        }, {
            a: "属性a2",
            b: "属性B2",
            c: "属性c2",
            sqr: "申请人2",
            status: 0,
            reason: "\r\n reason2"
        }]
    };
    a(data);


    function a(data) {
        if (data) {
            $("#tbody").empty();
            var bcList = data.lst;
            if (bcList.length) {
                bcList.forEach(function (value, index, arr) {
                    var tr = $("<tr></tr>").attr("id", "bcList" + value.id).append($("<td></td>").html(index));
                    for (var key in value) {
                        var text = value[key];
                        if (key == "status") {
                            continue;
                        }
                        if (key == "reason") {
                            text = (text || "").replace(/[\r\n]/g, "");
                        }
                        $("<td></td>").html(text).appendTo(tr);
                    }
                    var statusName = (value.status == 0) ? "待处理" : (value.status == 1) ? "通过" : "未通过";
                    tr.append($("<td></td>").text(statusName));

                    var btn1 = null;
                    var btn2 = null
                    if (value.status == "0") {
                        btn1 = $("<input>").addClass("btn_update").attr("type", "button").val("同意");
                        btn2 = $("<input>").addClass("btn_delete").attr("type", "button").val("不同意");
                        tr.append($("<td></td>").append(btn1).append(btn2));
                        btn1.click(function () {
                            //agree(value); //最好把整个对象当参数穿进去,这样下次加参数的时候agree接口不需要改变
                            agree(value.id, value.sqrName); //......很多其他参数没写
//							alert(1);
                        });
                        btn2.click(function () {
                            //disAgree(value);
                            disAgree(value.id, value.sqr); //......很多其他参数没写
//							alert(2);
                        });
                    } else {
                        tr.append($("<td></td>"));
                    }
                    $("#tbody").append(tr);
                });
            }
        }
    }
</script>
</body>
</html>